package com.yeung.ssm.service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.yeung.ssm.bean.Employee;
import com.yeung.ssm.dao.EmployeeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeService {
    @Autowired
    private EmployeeMapper employeeMapper;

    public Employee getEmpById(Integer id) {
        return employeeMapper.getEmpById(id);
    }

    public List<Employee> getEmps() {
        //由于使用了分页插件, 所以在目标查询方法之前设置分页限制即可
        Page<Object> page = PageHelper.startPage(1, 5);//第一页, 最多5条
        System.out.println("当前页码" + page.getPageNum());
        System.out.println("总记录数" + page.getTotal());
        System.out.println("每页的记录数" + page.getPageSize());
        System.out.println("总页码" + page.getPages());
        return employeeMapper.getEmps();
    }

}

